Understanding lists ( 'list comprehension') is basically to create lists based on existing iterables. It can also be described as representing for and if loops with a simpler and more attractive syntax. List comprehensions are relatively faster than for loops.
the way to create a List comprehension is as follows:
list = [expresión for iterador in iterable (condicional)] a = [4,6,7,3,2] b = [i for i in a if i > 4]Output:
[6,7]Understanding lists ( 'list comprehension') is basically to create lists based on existing iterables. It can also be described as representing for and if loops with a simpler and more attractive syntax. List comprehensions are relatively faster than for loops.
the way to create a List comprehension is as follows:
list = [expresión for iterador in iterable (condicional)] a = [4,6,7,3,2] b = [i for i in a if i > 4]Output:
[6,7]